package com.xiyu.service.controller.admin.restaurant;
import com.xiyu.service.vo.restaurant.dish.DishMultipleGetOutput;
import com.xiyu.service.vo.restaurant.dish.DishSingleGetOutput;
import com.xiyu.service.vo.restaurant.dish.DishListQueryDishTypeOutput;
import com.xiyu.service.vo.restaurant.dish.DishSingleGetDishTypeOutput;
import com.xiyu.service.vo.restaurant.dish.DishDishTypeUpdateInput;
import com.xiyu.service.vo.restaurant.dish.DishDishTypeCreateInput;
import com.xiyu.service.vo.restaurant.dish.DishPageQueryDishTypeOutput;
import com.xiyu.service.vo.restaurant.dish.DishPageQueryDishTypeInput;
import com.xiyu.service.vo.restaurant.dish.DishUpdateInput;
import com.xiyu.service.vo.restaurant.dish.DishCreateInput;
import com.xiyu.service.vo.restaurant.dish.DishQueryInput;
import com.xiyu.service.vo.restaurant.dish.DishQueryOutput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.restaurant.DishService;

@Tag(name = "菜品管理")
@RestController
@RequestMapping("/restaurant/dish")
@Validated
public class DishController {

    @Resource
    private DishService dishService;

    @GetMapping("/query")
    @Operation(summary = "分页查询菜品")
    @PreAuthorize("@ss.hasPermission('restaurant:dish:query')")
    public CommonResult<PageResult<DishQueryOutput>> query(@Valid DishQueryInput inputVO) {
        return success(dishService.query(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "创建菜品")
    @PreAuthorize("@ss.hasPermission('restaurant:dish:create')")
    public CommonResult<Long> create(@Valid @RequestBody DishCreateInput inputVO) {
        return success(dishService.create(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除菜品")
    @PreAuthorize("@ss.hasPermission('restaurant:dish:deleted')")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(dishService.deleted(id));
    }

    @PutMapping("/update")
    @Operation(summary = "更新菜品")
    @PreAuthorize("@ss.hasPermission('restaurant:dish:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody DishUpdateInput inputVO) {
        return success(dishService.update(inputVO));
    }

    @GetMapping("/page-query-dish-type")
    @Operation(summary = "分页查询菜品类型")
    @PreAuthorize("@ss.hasPermission('restaurant:dish-type:query')")
    public CommonResult<PageResult<DishPageQueryDishTypeOutput>> pageQueryDishType(@Valid DishPageQueryDishTypeInput inputVO) {
        return success(dishService.pageQueryDishType(inputVO));
    }

    @PostMapping("/dish-type-create")
    @Operation(summary = "创建菜品类型")
    @PreAuthorize("@ss.hasPermission('restaurant:dish-type:create')")
    public CommonResult<Long> dishTypeCreate(@Valid @RequestBody DishDishTypeCreateInput inputVO) {
        return success(dishService.dishTypeCreate(inputVO));
    }

    @PutMapping("/dish-type-update")
    @Operation(summary = "更新菜品类型")
    @PreAuthorize("@ss.hasPermission('restaurant:dish-type:update')")
    public CommonResult<Boolean> dishTypeUpdate(@Valid @RequestBody DishDishTypeUpdateInput inputVO) {
        return success(dishService.dishTypeUpdate(inputVO));
    }

    @DeleteMapping("/dish-type-delete")
    @Operation(summary = "删除菜品类型")
    @PreAuthorize("@ss.hasPermission('restaurant:dish-type:delete')")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> dishTypeDelete(@RequestParam("id") Long id) {
        return success(dishService.dishTypeDelete(id));
    }

    @GetMapping("/single-get-dish-type")
    @Operation(summary = "获取单个菜品类型")
    @Parameter(name = "id", description = "菜品类型主键ID", example = "")
    public CommonResult<DishSingleGetDishTypeOutput> singleGetDishType(@RequestParam("id") Long id) {
        return success(dishService.singleGetDishType(id));
    }

    @GetMapping("/list-query-dish-type")
    @Operation(summary = "查询菜品类型")
    public CommonResult<List<DishListQueryDishTypeOutput>> listQueryDishType() {
        return success(dishService.listQueryDishType());
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个菜品")
    @Parameter(name = "id", description = "菜品主键ID", example = "")
    public CommonResult<DishSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(dishService.singleGet(id));
    }

    @GetMapping("/multiple-get")
    @Operation(summary = "获取多个菜品")
    @Parameter(name = "ids", description = "菜品主键ID", example = "")
    public CommonResult<List<DishMultipleGetOutput>> multipleGet(@RequestParam("ids") List<Long> ids) {
        return success(dishService.multipleGet(ids));
    }

}
